YonYou - Client端开发 原创
UAP 创建生成
启动「UAP-STUDIO」,【文件】->【新建】->【其他】->【UAP Project development】->【UAP 业务项目】。创建过程的模板选择 ftpub。
接着继续创建「UAP 业务组件项目」。

【窗口】->【显示视图】->【其他】,打开 MDP 透视图。
对刚刚创建的 UAP 业务组件项目右键:新建实体组件,接着创建一个「实体」,并右键实体,找到特性,分别选择「组织信息、审计信息、富客户端单据信息」。

左键点击实体,在右边的「访问器类型」选择
AggVO,修改名称、显示名称,主属性选择 id
左键点击空白处,在右边的「代码风格」选择自定义样式

最后右键「发布元数据」,然后「生成 java 代码」
前端配置
回到项目,「UAP 中间件服务器」运行,运行成功后,再次在相同的位置「UAP 客户端」运行,来到了前端。
前端流程:
- 功能注册
- 菜单注册
- 菜单授权
- 单据模板初始化
- 查询模板初始化
- 默认模板输出

功能注册

菜单注册

菜单授权
【动态建模平台】->【权限管理】->【职责-集团】,进入权限管理。

首先点击查询,然后确定,就会查出很多的数据,点击末页,找到 yongyou_qq,打开。

然后把自己的菜单添加到右边。

单据模板初始化
搜索发布的实体,添加。

查询模板初始化
查询自己的模板编码。

进入修改界面,添加数据。

输入模板的信息,并且将数据库的字段拖到右边。

功能节点默认模板输出
所属银行和国家地区不需要填写。

后端配置
在前面我们已经创建了元数据的 Java 类,有三个:Agg 类、Agg 菜单类、实体类。
先看看后端的目录结构:

配置文件
配置文件类似于 Spring 的 xml,配置前端 URL 对应的处理类(Controller),这边是叫 Action。
当前端发送 URL 请求,则会在该文件找到与请求对应的 Action 类。
<?xml version="1.0" encoding="GBK"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- 环境变量 -->
<bean id="context" class="nc.vo.uif2.LoginContext"></bean>
<!-- 模型部分配置*********************************************************** -->
<!-- 应用服务类,负责进行模型操作的处理 -->
<bean id="bmModelModelService" class="nc.ui.ftpub.study.serviceproxy.AceStudyKbtClientServiceProxy"/>
<!-- 对象转换器工厂,由此获取操作对象的特征信息 -->
<bean id="BOAdapterFactory" class="nc.vo.bd.meta.GeneralBDObjectAdapterFactory">
<property name="mode" value="MD"/>
</bean>
<!-- 层次结构构造策略 -->
<!-- 模型元素 -->
<!--========= 模型元素:[PUBAPP平面模型(BillManageModel)实例对象] ==========-->
<bean id="bmModel" class="nc.ui.pubapp.uif2app.model.BillManageModel">
<property name="context"><ref bean="context"/></property>
<property name="businessObjectAdapterFactory"><ref bean="BOAdapterFactory"/></property>
</bean>
<!-- 数据模型管理器,主要负责各种方式的模型初始化 -->
<bean id="bmModelModelDataManager" class="nc.ui.pubapp.uif2app.query2.model.ModelDataManager">
<property name="model"><ref bean="bmModel"/></property>
<property name="service"><ref bean="bmModelModelService" /></property>
</bean>
<!-- Mediator,模型之间监听关系部分 -->
<!-- 组织面板//newadd -->
<!-- 卡片界面的工具栏和返回按钮 -->
<!-- 模板容器,负责对模板的统一装载 -->
<bean id="templateContainer" class="nc.ui.pubapp.uif2app.view.TemplateContainer" init-method="load">
<property name="context" ref="context"/>
<property name="nodeKeies">
<list>
<value>bt</value>
</list>
</property>
</bean>
<!-- 界面元素 ***********************************************************-->
<!--====== 视图元素:[查询区域控件实例对象] ==============-->
<bean id="viewa" class="nc.ui.pubapp.uif2app.tangramlayout.UEQueryAreaShell" init-method="initUI">
<property name="queryAreaCreator" ref="defaultQueryAction" />
</bean>
<!--====== 视图元素:[PUBAPP列表视图控件(ShowUpableBillListView)实例对象] ==============-->
<bean id="billListView" class="nc.ui.pubapp.uif2app.view.ShowUpableBillListView" init-method="initUI">
<property name="model"><ref bean="bmModel" /></property>
<property name="nodekey" value="bt" />
<!-- <property name="multiSelectionMode" value="1"/> -->
<!-- <property name="multiSelectionEnable" value="true" /> -->
<property name="templateContainer" ref="templateContainer"/>
<property name="showTotalLine" value="true" />
</bean>
<!--====== 视图元素:[卡片界面工具栏和返回按钮控件实例对象] ==============-->
<bean id="viewb" class="nc.ui.pubapp.uif2app.tangramlayout.UECardLayoutToolbarPanel" >
<property name="model"><ref bean="bmModel" /></property>
<property name="actions">
<list>
<ref bean="actionsBarSeparator" />
<ref bean="firstLineAction" />
<ref bean="preLineAction" />
<ref bean="nextLineAction" />
<ref bean="lastLineAction" />
<ref bean="actionsBarSeparator" />
</list>
</property>
<property name="titleAction">
<bean id="returnAction" class="nc.ui.pubapp.uif2app.actions.UEReturnAction">
<property name="goComponent" ref="billListView" />
<property name="saveAction" ref="saveScriptAction" />
<property name="model" ref="bmModel" />
</bean>
</property>
</bean>
<bean id="actionsBarSeparator" class="nc.ui.pub.beans.ActionsBar$ActionsBarSeparator" />
<!-- 浏览按钮 卡片界面共享信息按钮-->
<bean id="firstLineAction" class="nc.ui.uif2.actions.FirstLineAction">
<property name="model" ref="bmModel" />
</bean>
<bean id="nextLineAction" class="nc.ui.uif2.actions.NextLineAction">
<property name="model" ref="bmModel" />
</bean>
<bean id="preLineAction" class="nc.ui.uif2.actions.PreLineAction">
<property name="model" ref="bmModel" />
</bean>
<bean id="lastLineAction" class="nc.ui.uif2.actions.LastLineAction">
<property name="model" ref="bmModel" />
</bean>
<!--====== 视图元素:[PUBAPP表单控件(ShowUpableBillForm)实例对象] ==============-->
<bean id="billForm" class="nc.ui.pubapp.uif2app.view.ShowUpableBillForm" init-method="initUI">
<property name="model"><ref bean="bmModel" /></property>
<property name="showOrgPanel" value="false" />
<property name="nodekey" value="bt" />
</bean>
<!-- 界面布局总装*********************************************************** -->
<bean id="container" class="nc.ui.uif2.TangramContainer" init-method="initUI">
<property name="tangramLayoutRoot">
<bean class="nc.ui.uif2.tangramlayout.node.TBNode">
<property name="tabs">
<list>
<bean class="nc.ui.uif2.tangramlayout.node.HSNode">
<property name="left">
<bean class="nc.ui.uif2.tangramlayout.node.CNode">
<property name="component">
<ref bean="viewa" />
</property>
</bean>
</property>
<property name="right">
<bean class="nc.ui.uif2.tangramlayout.node.CNode">
<property name="component">
<ref bean="billListView" />
</property>
</bean>
</property>
<property name="dividerLocation" value="215.0f" />
<property name="name" value="列表" />
</bean>
<bean class="nc.ui.uif2.tangramlayout.node.VSNode">
<property name="up">
<bean class="nc.ui.uif2.tangramlayout.node.CNode">
<property name="component">
<ref bean="viewb" />
</property>
</bean>
</property>
<property name="down">
<bean class="nc.ui.uif2.tangramlayout.node.CNode">
<property name="component">
<ref bean="billForm" />
</property>
</bean>
</property>
<property name="dividerLocation" value="43.0f" />
<property name="name" value="卡片" />
</bean>
</list>
</property>
<property name="name" value="cardLayout" />
<property name="showMode" value="CardLayout" />
</bean>
</property>
<property name="actions">
<list>
<ref bean="addAction" />
<ref bean="editAction" />
<ref bean="deleteScriptAction" />
<ref bean="defaultQueryAction" />
<ref bean="separatorAction" />
<ref bean="defaultRefreshAction" />
<ref bean="separatorAction" />
<!-- <ref bean="defAction"/> -->
</list>
</property>
<property name="editActions">
<list>
<ref bean="saveScriptAction" />
<ref bean="cancelAction" />
</list>
</property>
<property name="model">
<ref bean="bmModel" />
</property>
<!--
<property name="model">
<ref bean="$vmObject.topActionDependModel"/>
</property>
-->
</bean>
<!-- 打开节点监听 newadd-->
<bean id="InitDataListener" class="nc.ui.pubapp.uif2app.model.DefaultFuncNodeInitDataListener">
<property name="model" ref="bmModel"/>
<property name="context" ref="context"></property>
<property name="voClassName" value="nc.vo.nccclient.study_client.AggStudyDemo"/>
</bean>
<!-- ClosingListener 编辑态关闭节点时提示是否保存//newadd***************************************************-->
<!-- 节点关闭前校验 -->
<bean id="ClosingListener" class="nc.ui.pubapp.common.validateservice.ClosingCheck" >
<property name="model" ref="bmModel" />
<property name="saveAction" ref="saveScriptAction" />
</bean>
<!-- 事件监听newadd -->
<bean id="bmModelEventMediator" class="nc.ui.pubapp.uif2app.model.AppEventHandlerMediator">
<property name="model" ref="bmModel" />
<property name="handlerGroup">
<list>
<!-- nc.ui.pubapp.uif2app.event.OrgChangedEvent -->
<!-- <bean class="nc.ui.pubapp.uif2app.event.EventHandlerGroup"> -->
<!-- <property name="event" value="nc.ui.pubapp.uif2app.event.OrgChangedEvent" /> -->
<!-- <property name="handler"> -->
<!-- <bean class="nc.ui.ftpub.study.handler.AceOrgChangeHandler" > -->
<!-- <property name="billForm" ref="billForm" /> -->
<!-- </bean> -->
<!-- </property> -->
<!-- </bean> -->
<!-- nc.ui.pubapp.uif2app.event.billform.AddEvent -->
<!-- <bean class="nc.ui.pubapp.uif2app.event.EventHandlerGroup"> -->
<!-- <property name="event" value="nc.ui.pubapp.uif2app.event.billform.AddEvent" /> -->
<!-- <property name="handler"> -->
<!-- <bean class="nc.ui.ftpub.study.handler.AceAddHandler" /> -->
<!-- </property> -->
<!-- </bean> -->
</list>
</property>
</bean>
<!--懒加载信息配置*******************************************************-->
<!-- 行号自动处理 -->
<!-- <bean id="rowNoMediator" class="nc.ui.pubapp.uif2app.view.RowNoMediator"> -->
<!-- <property name="model" ref="bmModel" /> -->
<!-- <property name="editor" ref="billForm" /> -->
<!-- </bean> -->
<!-- 双击列表行后显示卡片 -->
<bean id="mouseClickShowPanelMediator" class="nc.ui.pubapp.uif2app.view.MouseClickShowPanelMediator">
<property name="listView" ref="billListView" />
<property name="showUpComponent" ref="billForm" />
<property name="hyperLinkColumn" value="billno" />
</bean>
<!-- 单据号 -->
<!-- <bean id="billCodeMediator" class="nc.ui.pubapp.bill.BillCodeMediator" init-method="initUI"> -->
<!-- <property name="billForm" ref="billForm"></property> -->
<!-- <property name="billCodeKey" value="billno"></property> -->
<!-- <property name="billType" value="HQSA"></property> -->
<!-- </bean> -->
<!-- Action部分 ***********************************************************-->
<!--======= 动作:[newActions] [新增] ===========-->
<bean id="addAction" class="nc.ui.pubapp.uif2app.actions.AddAction">
<property name="model"><ref bean="bmModel"/></property>
<property name="interceptor">
<bean class="nc.ui.pubapp.uif2app.actions.interceptor.CompositeActionInterceptor">
<property name="interceptors">
<list>
<bean class="nc.ui.pubapp.uif2app.actions.interceptor.ShowUpComponentInterceptor">
<property name="showUpComponent" ref="billForm" />
</bean>
<!--此处可以扩展添加自己的拦截器-->
</list>
</property>
</bean>
</property>
<property name="exceptionHandler"><ref bean="exceptionHandler" /></property>
</bean>
<bean id="cardRefreshAction" class="nc.ui.pubapp.uif2app.actions.RefreshSingleAction">
<property name="model" ref="bmModel" />
</bean>
<!--======= 动作:[newActions] [修改] ===========-->
<bean id="editAction" class="nc.ui.pubapp.uif2app.actions.EditAction">
<property name="model"><ref bean="bmModel"/></property>
<property name="interceptor">
<bean class="nc.ui.pubapp.uif2app.actions.interceptor.CompositeActionInterceptor">
<property name="interceptors">
<list>
<bean class="nc.ui.pubapp.uif2app.actions.interceptor.ShowUpComponentInterceptor">
<property name="showUpComponent" ref="billForm" />
</bean>
<!--此处可以扩展添加自己的拦截器-->
</list>
</property>
</bean>
</property>
<property name="exceptionHandler"><ref bean="exceptionHandler" /></property>
</bean>
<!--======= 动作:[newActions] [删除] ===========-->
<bean id="deleteScriptAction" class="nc.ui.pubapp.uif2app.actions.pflow.DeleteScriptAction">
<property name="model"><ref bean="bmModel"/></property>
<property name="billType" value="HQSA" />
<property name="filledUpInFlow" value="true" />
<property name="actionName" value="DELETE" />
<property name="exceptionHandler"><ref bean="exceptionHandler" /></property>
</bean>
<!-- <bean id="deleteScriptAction" class="nc.ui.pubapp.uif2app.actions.DeleteAction"> -->
<!-- <property name="model"><ref bean="bmModel"/></property> -->
<!-- <property name="exceptionHandler"><ref bean="exceptionHandler" /></property> -->
<!-- </bean> -->
<bean id="defaultQueryActionQueryTemplateContainer" class="nc.ui.uif2.editor.QueryTemplateContainer">
<property name="nodeKey" value="qt" />
<property name="context"><ref bean="context"/></property>
</bean>
<!--======= 动作:[newActions] [查询] ===========-->
<bean id="defaultQueryAction" class="nc.ui.pubapp.uif2app.query2.action.DefaultQueryAction">
<property name="model"><ref bean="bmModel"/></property>
<property name="templateContainer"><ref bean="defaultQueryActionQueryTemplateContainer" /></property>
<property name="nodeKey" value="qt"></property>
<property name="dataManager"><ref bean="bmModelModelDataManager"/></property>
<!-- <property name="qryCondDLGInitializer"><ref bean="qryCondDLGInitializer"/></property> -->
<property name="exceptionHandler"><ref bean="exceptionHandler" /></property>
<property name="btnName" value="查询" />
</bean>
<!-- <bean id="qryCondDLGInitializer" class="nc.ui.ftm_ftax.fta_agricloan_info.ace.query.QueryDLGInitializer"/> -->
<!--======= 动作:[newActions] [刷新] ===========-->
<bean id="defaultRefreshAction" class="nc.ui.pubapp.uif2app.query2.action.DefaultRefreshAction">
<property name="model"><ref bean="bmModel"/></property>
<property name="dataManager"><ref bean="bmModelModelDataManager"/></property>
<property name="exceptionHandler"><ref bean="exceptionHandler" /></property>
</bean>
<!--======= 动作:[newActions] [提交按钮组] ===========-->
<bean id="commitScriptGroup" class="nc.funcnode.ui.action.GroupAction">
<property name="code" value="commitScriptGroup" />
<property name="name" value="提交" />
<property name="actions">
<list>
<ref bean="commitScriptAction" />
<ref bean="unCommitScriptAction" />
</list>
</property>
</bean>
<!--======= 动作:[newActions] [提交] ===========-->
<bean id="commitScriptAction" class="nc.ui.pubapp.uif2app.actions.pflow.CommitScriptAction">
<property name="model"><ref bean="bmModel"/></property>
<property name="editor"><ref bean="billForm"/></property>
<property name="billType" value="HQSA" />
<property name="filledUpInFlow" value="true" />
<property name="actionName" value="SAVE" />
<property name="exceptionHandler"><ref bean="exceptionHandler" /></property>
</bean>
<!--======= 动作:[newActions] [收回] ===========-->
<bean id="unCommitScriptAction" class="nc.ui.pubapp.uif2app.actions.pflow.UnCommitScriptAction">
<property name="model"><ref bean="bmModel"/></property>
<property name="editor"><ref bean="billForm"/></property>
<property name="billType" value="HQSA" />
<property name="filledUpInFlow" value="true" />
<property name="actionName" value="UNSAVEBILL" />
<property name="exceptionHandler"><ref bean="exceptionHandler" /></property>
</bean>
<!--======= 动作:[newActions] [审核按钮组] ===========-->
<bean id="approveScriptGroup" class="nc.funcnode.ui.action.GroupAction">
<property name="code" value="approveScriptGroup" />
<property name="name" value="审核" />
<property name="actions">
<list>
<ref bean="approveScriptAction" />
<ref bean="uNApproveScriptAction" />
</list>
</property>
</bean>
<!--======= 动作:[newActions] [审批] ===========-->
<bean id="approveScriptAction" class="nc.ui.pubapp.uif2app.actions.pflow.ApproveScriptAction">
<property name="model"><ref bean="bmModel"/></property>
<property name="editor"><ref bean="billForm"/></property>
<property name="billType" value="HQSA" />
<property name="filledUpInFlow" value="true" />
<property name="actionName" value="APPROVE" />
<property name="exceptionHandler"><ref bean="exceptionHandler" /></property>
</bean>
<!--======= 动作:[newActions] [取消审批] ===========-->
<bean id="uNApproveScriptAction" class="nc.ui.pubapp.uif2app.actions.pflow.UNApproveScriptAction">
<property name="model"><ref bean="bmModel"/></property>
<property name="editor"><ref bean="billForm"/></property>
<property name="billType" value="HQSA" />
<property name="filledUpInFlow" value="true" />
<property name="actionName" value="UNAPPROVE" />
<property name="exceptionHandler"><ref bean="exceptionHandler" /></property>
</bean>
<!--======= 动作:[newActions] [预览] ===========-->
<bean id="metaDataBasedPrintAction" class="nc.ui.pubapp.uif2app.actions.MetaDataBasedPrintAction">
<property name="model"><ref bean="bmModel"/></property>
<property name="actioncode" value="Preview"></property>
<property name="actionname" value="预览"></property>
<property name="preview" value="true"></property>
<property name="nodeKey" value="ot" />
<property name="exceptionHandler"><ref bean="exceptionHandler" /></property>
<property name="btnName" value="预览" />
</bean>
<!--======= 动作:[newActions] [打印] ===========-->
<bean id="metaDataBasedPrintActiona" class="nc.ui.pubapp.uif2app.actions.MetaDataBasedPrintAction">
<property name="model"><ref bean="bmModel"/></property>
<property name="actioncode" value="Print"></property>
<property name="actionname" value="打印"></property>
<property name="preview" value="false"></property>
<property name="nodeKey" value="ot" />
<property name="exceptionHandler"><ref bean="exceptionHandler" /></property>
<property name="btnName" value="打印" />
</bean>
<!--======= 动作:[newActions] [输出...] ===========-->
<bean id="outputAction" class="nc.ui.pubapp.uif2app.actions.OutputAction">
<property name="model"><ref bean="bmModel"/></property>
<property name="editor"><ref bean="billForm"/></property>
<property name="nodeKey" value="ot" />
<property name="exceptionHandler"><ref bean="exceptionHandler" /></property>
</bean>
<!--======= 动作:[newActions] [查看审批意见] ===========-->
<bean id="pFApproveStatusInfoAction" class="nc.ui.pubapp.uif2app.actions.pflow.PFApproveStatusInfoAction">
<property name="model"><ref bean="bmModel"/></property>
<property name="billType" value="HQSA" />
<property name="exceptionHandler"><ref bean="exceptionHandler" /></property>
</bean>
<!--======= 动作:[newActions] [保存] ===========-->
<!-- <bean id="saveScriptAction" class="nc.ui.pubapp.uif2app.actions.pflow.SaveScriptAction"> -->
<!-- <property name="model"><ref bean="bmModel"/></property> -->
<!-- <property name="editor"><ref bean="billForm"/></property> -->
<!-- <property name="billType" value="HQSA" /> -->
<!-- <property name="filledUpInFlow" value="true" /> -->
<!-- <property name="actionName" value="SAVEBASE" /> -->
<!-- <property name="validationService" ref="saveValidateService" /> -->
<!-- <property name="exceptionHandler"><ref bean="exceptionHandler" /></property> -->
<!-- </bean> -->
<bean id="saveScriptAction" class="nc.ui.ftpub.study.action.AceSaveAction">
<!-- <bean id="saveScriptAction" class="nc.ui.pubapp.uif2app.actions.SaveAction"> -->
<property name="model"><ref bean="bmModel"/></property>
<property name="editor"><ref bean="billForm"/></property>
<!-- <property name="validationService" ref="saveValidateService" /> -->
<property name="exceptionHandler"><ref bean="exceptionHandler" /></property>
</bean>
<!--======= 动作:[newActions] [取消] ===========-->
<bean id="cancelAction" class="nc.ui.pubapp.uif2app.actions.CancelAction">
<property name="model"><ref bean="bmModel"/></property>
<property name="editor"><ref bean="billForm"/></property>
<property name="exceptionHandler"><ref bean="exceptionHandler" /></property>
</bean>
<!--======= 动作:[newActions] [测试按钮] ===========-->
<bean id="defAction" class="nc.ui.ftpub.study.action.DefAction">
<property name="model"><ref bean="bmModel"/></property>
<property name="exceptionHandler"><ref bean="exceptionHandler" /></property>
</bean>
<!--分隔按钮-->
<bean id="separatorAction" class="nc.funcnode.ui.action.SeparatorAction" />
<bean id="exceptionHandler" class="nc.ui.uif2.DefaultExceptionHanler">
<constructor-arg><ref bean="container"/></constructor-arg>
<property name="context"><ref bean="context" /></property>
</bean>
<!-- 批量保存校验服务类 -->
<!--保存校验 -->
<!-- <bean id="saveValidateService" class="nc.ui.pubapp.uif2app.validation.CompositeValidation"> -->
<!-- <property name="validators"> -->
<!-- <list> -->
<!-- <bean class="nc.ui.ftpub.study.validate.SaveRuleValidation"> -->
<!-- </bean> -->
<!-- </list> -->
<!-- </property> -->
<!-- </bean> -->
</beans>Client 的 Action 类
Action 类类似于 Spring 的 Controller,专门处理前端发送的请求,并分配到 Service 类。Action 位于 Client 模块下。
这里只是写了保存的 Action 类,实际还有其他的 Action 类,如增删改。
import java.awt.event.ActionEvent;
import nc.bs.framework.common.NCLocator;
import nc.ui.pubapp.uif2app.actions.SaveAction;
import nc.ui.uif2.UIState;
import nc.ui.uif2.model.HierachicalDataAppModel;
import nc.vo.ftpub.studydemokbt.AggStudyEntitykbt;
import nc.vo.ftpub.studydemokbt.itf.IStudyKbtClientService;
public class AceSaveAction extends SaveAction {
public AceSaveAction() {
super();
}
public void doAction(ActionEvent e) throws Exception {
Object value = getEditor().getValue();
validate(value);
if(getModel().getUiState()==UIState.ADD){
doAddSave(value);
}else if(getModel().getUiState()==UIState.EDIT){
doEditSave(value);
}
showSuccessInfo();
}
protected void doEditSave(Object value) throws Exception {
// getModel().update(value);
IStudyKbtClientService service = NCLocator.getInstance().lookup(IStudyKbtClientService.class);
service.update(new AggStudyEntitykbt[]{(AggStudyEntitykbt) value}, null);
getModel().setUiState(UIState.NOT_EDIT);
getModel().setOtherUiState(UIState.NOT_EDIT);
}
protected void doAddSave(Object value) throws Exception {
// Object returnObj = getModel().add(value);
IStudyKbtClientService service = NCLocator.getInstance().lookup(IStudyKbtClientService.class);
AggStudyEntitykbt[] returnObjArr = service.insert(new AggStudyEntitykbt[]{(AggStudyEntitykbt) value}, null);
getModel().setUiState(UIState.NOT_EDIT);
getModel().setOtherUiState(UIState.NOT_EDIT);
if(getModel() instanceof HierachicalDataAppModel)
((HierachicalDataAppModel)getModel()).setSelectedData(returnObjArr[0]);
}
}查询的 Action
package nc.ui.ftpub.study.serviceproxy;
import nc.bs.framework.common.NCLocator;
import nc.ui.pubapp.uif2app.query2.model.IQueryService;
import nc.ui.querytemplate.querytree.IQueryScheme;
import nc.vo.ftpub.studydemokbt.itf.IStudyKbtClientService;
public class AceStudyKbtClientServiceProxy implements IQueryService {
@Override
public Object[] queryByQueryScheme(IQueryScheme queryScheme) throws Exception {
IStudyKbtClientService service = NCLocator.getInstance().lookup(IStudyKbtClientService.class);
return service.query(queryScheme);
}
}public 的 Service 接口
Service 接口位于 public 模块下。
public interface IStudyKbtClientService {
// 删除
public void delete(AggStudyEntitykbt[] clientFullVOs, AggStudyEntitykbt[] originBills) throws BusinessException;
// 添加
public AggStudyEntitykbt[] insert(AggStudyEntitykbt[] clientFullVOs, AggStudyEntitykbt[] originBills) throws BusinessException;
// 修改
public AggStudyEntitykbt[] update(AggStudyEntitykbt[] clientFullVOs, AggStudyEntitykbt[] originBills) throws BusinessException;
// 查询
public AggStudyEntitykbt[] query(IQueryScheme queryScheme) throws BusinessException;
}private 的 Service 实现类
因为 Service 实现类与数据库交互所以放在 private 模块下,提高安全性。
public class StudyKbtClientImpl extends AceStudyKbtClientImpl implements IStudyKbtClientService {
@Override
public void delete(AggStudyEntitykbt[] clientFullVOs,
AggStudyEntitykbt[] originBills) throws BusinessException {
super.pubdeleteBills(clientFullVOs, originBills);
}
@Override
public AggStudyEntitykbt[] insert(AggStudyEntitykbt[] clientFullVOs,
AggStudyEntitykbt[] originBills) throws BusinessException {
return super.pubinsertBills(clientFullVOs, originBills);
}
@Override
public AggStudyEntitykbt[] update(AggStudyEntitykbt[] clientFullVOs,
AggStudyEntitykbt[] originBills) throws BusinessException {
return super.pubupdateBills(clientFullVOs, originBills);
}
@Override
public AggStudyEntitykbt[] query(IQueryScheme queryScheme)
throws BusinessException {
return super.pubquerybills(queryScheme);
}
}下面是实际的处理实现类,上面的流程最终都汇集在这个类。
public class AceStudyKbtClientImpl {
// 新增
public AggStudyEntitykbt[] pubinsertBills(AggStudyEntitykbt[] clientFullVOs,
AggStudyEntitykbt[] originBills) throws BusinessException {
//try {
// 数据库中数据和前台传递过来的差异VO合并后的结果
//BillTransferTool<AggStudyEntitykbt> transferTool = new BillTransferTool<AggStudyEntitykbt>(clientFullVOs);
// 调用BP
//AceStudyClientInsertBP action = new AceStudyClientInsertBP();
//AggStudyEntitykbt[] retvos = action.insert(clientFullVOs);
// 构造返回数据
//return transferTool.getBillForToClient(retvos);
//} catch (Exception e) {
//ExceptionUtils.marsh(e);
//}
BaseDAO dao = new BaseDAO();
String code = clientFullVOs[0].getParentVO().getCode();
String name = clientFullVOs[0].getParentVO().getName();
double id = Math.random() * 10;
StringBuffer sql = new StringBuffer();
SQLParameter sqlParamter = new SQLParameter();
sql.append("INSERT INTO bd_tang_lsp(PK_BD_TANG_LSP,CODE,NAME) VALUES (?,?,?)");
sqlParamter.addParam(id);
sqlParamter.addParam(code);
sqlParamter.addParam(name);
dao.executeUpdate(sql.toString(), sqlParamter);
return null;
}
// 删除
public void pubdeleteBills(AggStudyEntitykbt[] clientFullVOs,
AggStudyEntitykbt[] originBills) throws BusinessException {
//try {
// 调用BP
//new AceFta_agricloan_infoDeleteBP().delete(clientFullVOs);
//} catch (Exception e) {
//ExceptionUtils.marsh(e);
//}
BaseDAO dao = new BaseDAO();
String code = clientFullVOs[0].getParentVO().getCode();
String name = clientFullVOs[0].getParentVO().getName();
double id = Math.random() * 10;
StringBuffer sql = new StringBuffer();
SQLParameter sqlParamter = new SQLParameter();
sql.append("DELETE bd_tang_lsp WHERE PK_BD_TANG_LSP = '?'");
sqlParamter.addParam(id);
//dao.executeUpdate(sql.toString(), sqlParamter);
}
// 修改
public AggStudyEntitykbt[] pubupdateBills(AggStudyEntitykbt[] clientFullVOs,
AggStudyEntitykbt[] originBills) throws BusinessException {
//try {
// 加锁 + 检查ts
//BillTransferTool<AggStudyEntitykbt> transferTool = new BillTransferTool<AggStudyEntitykbt>(clientFullVOs);
//AceFta_agricloan_infoUpdateBP bp = new AceFta_agricloan_infoUpdateBP();
//AggStudyEntitykbt[] retvos = bp.update(clientFullVOs, originBills);
// 构造返回数据
//return transferTool.getBillForToClient(retvos);
//} catch (Exception e) {
//ExceptionUtils.marsh(e);
//}
BaseDAO dao = new BaseDAO();
String code = clientFullVOs[0].getParentVO().getCode();
String name = clientFullVOs[0].getParentVO().getName();
double id = Math.random() * 10000;
StringBuffer sql = new StringBuffer();
SQLParameter sqlParamter = new SQLParameter();
sql.append("UPDATE bd_tang_lsp SET CODE = ? WHERE PK_BD_TANG_LSP = '1001ZZ10000000018QCW'");
sqlParamter.addParam(code);
dao.executeUpdate(sql.toString(), sqlParamter);
return null;
}
public AggStudyEntitykbt[] pubquerybills(IQueryScheme queryScheme)
throws BusinessException {
//AggStudyEntitykbt[] bills = null;
//try {
//this.preQuery(queryScheme);
//BillLazyQuery<AggStudyEntitykbt> query = new BillLazyQuery<AggStudyEntitykbt>(AggStudyEntitykbt.class);
//bills = query.query(queryScheme, null);
//} catch (Exception e) {
//ExceptionUtils.marsh(e);
//}
BaseDAO dao = new BaseDAO();
StringBuffer sql = new StringBuffer();
sql.append("select code,name,pk_group,pk_org,pk_org,creator,creationtime id from org_orgs where dr = 0");
if(null != queryScheme.getWhereSQLOnly() && queryScheme.getWhereSQLOnly().trim().length() > 0){
sql.append(" and ");
sql.append(queryScheme.getWhereSQLOnly());
}
List<StudyEntitykbt> list = (List<StudyEntitykbt>) dao.executeQuery(sql.toString(), new BeanListProcessor(StudyEntitykbt.class));
AggStudyEntitykbt[] bills = null;
if(null != list && list.size() > 0 ){
bills = new AggStudyEntitykbt[list.size()];
for (int index = 0; index < bills.length; index++) {
bills[index] = new AggStudyEntitykbt();
bills[index].setParentVO(list.get(index));
}
}
return bills;
}
/**
* 由子类实现,查询之前对queryScheme进行加工,加入自己的逻辑
*
* @param queryScheme
*/
protected void preQuery(IQueryScheme queryScheme) throws BusinessException {
}
}注册 Service
最后一步还需要注册 Service 的接口和实现类,让系统知道位置,并且配置事务、单例等信息。
在组件的 META-INF 文件下创建一个 upm 文件
<?xml version="1.0" encoding="gb2312"?>
<module name="emm">
<public>
<component priority="0" singleton="true" remote="true" tx="CMT" supportAlias="true">
<interface>nc.vo.ftpub.studydemokbt.itf.IStudyKbtClientService</interface>
<implementation>nc.impl.StudyKbtClientImpl</implementation>
</component>
</public>
</module>结构如图:
